package com.gt.deceive.utils;


import org.apache.commons.lang3.StringUtils;

import java.io.*;
import java.util.HashMap;

/**
 * 支付zj
 *
 */
public class payzj {
    public static void main(String[] args) {
        // 在E盘下新建一个文本文件
        File file1 = new File("/Users/wanghuiyong/why/all1.txt"); // 创建File类对象
        FileInputStream fis = null; // 创建FileInputStream类对象读取File
        InputStreamReader isr = null; // 创建InputStreamReader对象接收文件流
        BufferedReader br = null; // 创建reader缓冲区将文件流装进去
        try {
            fis = new FileInputStream(file1);
            isr = new InputStreamReader(fis);
            br = new BufferedReader(isr);
            String lineTxt = null;
            // 从缓冲区中逐行读取代码，调用readLine()方法
            while ((lineTxt = br.readLine()) != null) {
                System.out.println(lineTxt); // 逐行输出文件内容
                send(lineTxt);
            }

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            // 文件执行完毕别忘了关闭数据流
            if (br != null) {
                try {
                    br.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (isr != null) {
                try {
                    isr.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (fis != null) {
                try {
                    fis.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    public static void send(String code){
        if(!StringUtils.isBlank(code)){
            HttpHelper h = new HttpHelper();
            HashMap p = new HashMap();
            p.put("orderCode", code.trim());
            String res = null;
            try {
                res = h.postData2("http://generalstore.gtexpress.cn/wtorder/api/order/onLinePayCallBack", p, "UTF-8", 10, 1);
            } catch (Exception e) {
                e.printStackTrace();
            }
            System.out.println(code+"-------" + res);
        }else{
            System.out.println("单号为空");
        }
    }
}
